package com.ssyt.lms.sys.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ssyt.lms.entity.RightInfo;
import com.ssyt.lms.entity.UserInfo;
import com.ssyt.lms.sys.dao.InitSystemMapper;

@Service("initSystemService")
@Transactional
public class InitSystemServiceImpl implements IInitSystemService {
	
	@Autowired
	@Qualifier("initSystemMapper")
	private InitSystemMapper initMapper;

	@Override
	public List<RightInfo> getMainMenuByRoleId(UserInfo user) {
		return initMapper.getMainMenuByRoleId(user);
	}

	@Override
	public List<RightInfo> getChildrenMenuByParentId(RightInfo right,String url) {
		List<RightInfo> rights = initMapper.getChildrenMenuByParentId(right);
		if (null!=rights && rights.size()>0) {
			for (RightInfo rightInfo : rights) {
				String href = rightInfo.getHref();
				href=url+href; // http://localhost:8088/LMSP/
				rightInfo.setHref(href);
			}
		}
		return rights;
	}

}
